@extends('layouts.app')
@include('coupon.sidebar')
@section('content')
    <div class="content">
        <div class="row custom-invoice">
            @can('coupon-record-edit')
                <a class="btn btn-success" href="{{ route("admin.coupon.user.create") }}">发放优惠券</a>
            @endcan
            <br />
            <br />
            <table class="table table-striped table-hover">
                <thead>
                <tr>
                    <th>用户名称</th>
                    <th>用户头像</th>
                    <th>优惠券类型</th>
                    <th>优惠券</th>
                    <th>金额</th>
                    <th>过期时间</th>
                    <th>使用时间</th>
                    <th>使用订单id</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @foreach($data as $item)
                    <tr>
                        <td>{{ $user->get($item->user_id)->nickname }}</td>
                        <td>
                            <img src="{{ $user->get($item->user_id)->avatar }}" width="30">
                        </td>
                        <td>{{ \App\Modules\Coupon\Models\Coupon::$typeShow[$item->type] }}</td>
                        <td>{{ $item->title }}</td>
                        <td>{{ $item->money/100  }}</td>
                        <td>{{ $item->expiration_date }}</td>
                        <td>{{ $item->use_time }}</td>
                        <td>{{ $item->use_id }}</td>
                        <td>
                            @can('coupon-record-edit')
                                @if(empty($item->use_time))
                                    <a class="btn btn-primary btn-xs" data-method="delete" href="{{ route('admin.coupon.user.cancel', ['id' => $item->id]) }}"><i class="fa fa-ban"></i> 作废</a>
                                @endif
                            @endcan
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
            {{ $data->links() }}
        </div>
    </div>
@endsection
